package com.yxy.springcloud.framework.microservice1.hystrixTest;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;

public class CommandHelloFailure extends HystrixCommand<String> {

  private final String name;

  public CommandHelloFailure(String name) {
    super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
    this.name = name;
  }

  @Override
  protected String run() {
    throw new RuntimeException("this command always fails");
  }

  @Override
  protected String getFallback() {
    return "Hello Failure " + name + "!";
  }

  public static void main(String[] args) {
    String result = new CommandHelloFailure("yxy").execute();
    System.err.println("result------------>"+ result);
  }
}
